﻿using FlyingEye.ESApplication.Models.PowderProcess;
using FlyingEye.ESApplication.Services;
using FlyingEye.MixingProcess.PowderProcess;
using FlyingEye.Repositories;
using System.Threading.Tasks;
using Volo.Abp.ObjectMapping;

namespace FlyingEye.Services
{
    /// <summary>
    /// 粉料工序服务
    /// </summary>
    internal class PowderProcessService : IPowderProcessService
    {
        private readonly IObjectMapper _mapper;

        private readonly PowderProcessRepository _repository;

        public PowderProcessService(IObjectMapper mapper, PowderProcessRepository repository)
        {
            _mapper = mapper;
            _repository = repository;
        }

        public async Task RecordPowderProcessCompletion(PowderProcessCompletion model)
        {
            var record = _mapper.Map<PowderProcessCompletion, PowderProcessCompletionRecord>(model);
            await _repository.InsertAsync(record);
        }

        public async Task RecordPowderFeedingAlarm(PowderFeedingAlarm model)
        {
            var record = _mapper.Map<PowderFeedingAlarm, PowderFeedingAlarmRecord>(model);
            await _repository.InsertAsync(record);
        }

        public async Task RecordMixingEquipmentAlarm(MixingEquipmentAlarm model)
        {
            var record = _mapper.Map<MixingEquipmentAlarm, MixingEquipmentAlarmRecord>(model);
            await _repository.InsertAsync(record);
        }
    }
}
